package com.hicoffee.bm.controller;


import com.hicoffee.bm.model.CustomerTerminal;
import com.hicoffee.bm.service.CustomerTerminalService;
import com.hicoffee.bm.utils.ResponseUtil;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import com.radarwin.framework.web.controller.BaseController;
import com.radarwin.framework.web.response.ResponseWrapper;
import com.radarwin.framework.util.StringUtil;



/**
 *  auto generated by generation tools v1.0.0
 */
@Controller
@RequestMapping("/customerTerminal")
public class CustomerTerminalController extends BaseController {



    @Autowired
    private CustomerTerminalService customerTerminalService;




	@RequestMapping(value = "/pageList")
	@ResponseBody
	public ResponseWrapper getCustomerTerminalPageList (HttpServletRequest request) {
		return customerTerminalService.getCustomerTerminalPageList(convertParamToMap(request));
	}





    @RequestMapping(value = "/get")
    @ResponseBody
    public ResponseWrapper get(String id) {
        CustomerTerminal customerTerminal = new CustomerTerminal();
        if (StringUtil.isNotBlank(id)) {
           customerTerminal= customerTerminalService.selectByKey(id);
        }
        return ResponseUtil.successResponse("customerTerminal",customerTerminal);
    }

    @RequestMapping(value = "/add")
	@ResponseBody
	public ResponseWrapper create(CustomerTerminal customerTerminal) {
        int result = customerTerminalService.insert(customerTerminal);
        if(result>0){
            return ResponseUtil.successResponse("新增成功");
        }
		return ResponseUtil.successResponse("新增失败");
	}


    @RequestMapping(value = "/update")
	@ResponseBody
	public ResponseWrapper update(CustomerTerminal customerTerminal) {
		int result = customerTerminalService.update(customerTerminal);
        if(result>0){
            return ResponseUtil.successResponse("更新成功");
        }
        return ResponseUtil.successResponse("更新失败");
	}


	@RequestMapping(value = "/delete")
    @ResponseBody
    public ResponseWrapper delete(String ids) {
        CustomerTerminal customerTerminal = new CustomerTerminal();
        int result=0;
        if (StringUtil.isNotBlank(ids)) {
            customerTerminal.setId(Long.valueOf(ids));
            customerTerminal.setDeleted(true);
            result = customerTerminalService.update(customerTerminal);
        }
    	if(result>0){
            return ResponseUtil.errorResponse("删除成功");
        }
        return ResponseUtil.errorResponse("删除失败");
    }




}
